#include "../src/linkstack/linkstack.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* 声明底层栈的函数库 */
extern func_LinkStack fun_LinkStack;

#define CAPACITY 10

int main(int argc, const char *argv[])
{
    int i = 0;
    int a[CAPACITY] = {0};
    LinkStack *stack = fun_LinkStack.create();

    if (stack == NULL)
        return -1;

    // 压栈
    for (i = 0; i < CAPACITY; i++)
    {
        a[i] = i + 1;
        fun_LinkStack.push(stack, &a[i]);
    }

    printf("目前长度为 ： %d\n", fun_LinkStack.length(stack));
    printf("栈顶数据为 ： %d\n", *((int *)fun_LinkStack.top(stack)));
    printf("\n");

    while (fun_LinkStack.length(stack) > 0)
    {
        LinkStackNode *tmp = fun_LinkStack.pop(stack);
        printf("出栈的数据为 ：%d\n", *((int *)tmp));
    }

    printf("\n");

    return 0;
}
